package org.iqiyi.util.excel;


import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @class_name: PoiExcelThreadPool
 * @description: excel操作线程池
 * @Author: huqi
 * @Create_time: 11:20 2021-3-19
 **/
public class PoiExcelThreadPool {

    /**
     * 阻塞队列
     */
    public static BlockingQueue queue;
    /**
     * 线程池
     */
    private static ThreadPoolExecutor threadPoolExecutor;

    static {
        queue = new ArrayBlockingQueue(1024);
        threadPoolExecutor = new ThreadPoolExecutor(40
                , 50
                , 60L
                , TimeUnit.MILLISECONDS
                , queue
                , new ThreadPoolExecutor.CallerRunsPolicy());
    }

    /**
     * 获取线程池大小
     *
     * @return
     */
    public static Integer getPoolSize() {
        return threadPoolExecutor.getPoolSize();
    }

    /**
     * 获取线程池
     *
     * @return
     */
    public static ThreadPoolExecutor getThreadPoolExecutor() {
        return threadPoolExecutor;
    }

}
